package com.xcity.game.equip.suit4.impl;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.Combat;
import com.xcity.game.combat.CombatTeam;
import com.xcity.game.combat.CombatUtils;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.equip.suit4.BaseSuit4;
import com.xcity.game.equip.template.EquipSuitEffectTemplate;

/**
 * 普拉达4件套<br/>
 * 在行动结束时有{20}%的几率获得额外一次行动机会
 * @author yang.li
 *
 */
public class Suit4Prada extends BaseSuit4 {

	public Suit4Prada(CombatUnit unit, EquipSuitEffectTemplate template) {
		super(unit, template);
	}

	@Override
	public void afterAction(Action action) {
		if (unit.getId() != action.getUnitId()) {
			return;
		}
		if (Combat.RND.nextInt(GameStaticConfig.percentBase) < template.getSuit4Param(0)) {
			Action newAct = new Action(action.unit);
			CombatTeam ct = action.ref().ref().getHitTargetTeam(action.unit);
			CombatUnit target = ct.getDefenseUnit(action.unit.getIndex());
			if (target == null) {
				return;
			}
			action.ref().add(newAct);
			ActionEffect eff = newAct.addTarget(target);
			CombatUtils.calcAttack(eff);
		}
	}
	

}
